//
//  NSString+font.m
//  打车小界面
//
//  Created by 哥吸进去的是烟，吐出的是寂寞 on 16/4/25.
//  Copyright © 2016年 哥吸进去的是烟，吐出的是寂寞. All rights reserved.
//

#import "NSString+font.h"

@implementation NSString (font)

//去除字符串前后空格
-(NSString*)Trim{
    if (self) {
        //whitespaceAndNewlineCharacterSet 去除前后空格与回车
        //whitespaceCharacterSet 除前后空格
        return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    }
    return @"";
}

-(NSString *)TrimWhites
{
    if (self) {
        //whitespaceAndNewlineCharacterSet 去除前后空格与回车
        //whitespaceCharacterSet 除前后空格
        return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    }
    return @"";
}


#pragma mark - 判断字符串是否为null @“”
+ (BOOL)isBlankString:(NSString *)string
{
    if (nil == string) {
        return YES;
    }
    NSString *temp = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    if (temp == nil) {
        return YES;
    }
    if (temp == NULL) {
        return YES;
    }
    if ([temp isKindOfClass:[NSNull class]]) {
        return YES;
    }
    if(temp.length < 1){
        return YES;
    }
    return NO;
}


/**
 *@method 判断是否为整形
 *@param string 字符数据
 */
+(BOOL)isPureInt:(NSString *)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    int val;
    return [scan scanInt:&val] && [scan isAtEnd];
}

#pragma mark - 判断是否为浮点形
+(BOOL)isPureFloat:(NSString *)string{
    NSScanner* scan = [NSScanner scannerWithString:string];
    float val;
    return [scan scanFloat:&val] && [scan isAtEnd];
}



@end


@implementation NSString (substring)

-(NSString *)onFromIndex:(NSInteger)index
{
    if(kStringIsEmpty(self)==YES)return @"";
    
    return [self substringFromIndex:index];
}
-(NSString *)onToIndex:(NSInteger)index
{
      if(kStringIsEmpty(self)==YES)return @"";
    return [self substringToIndex:index];
}

@end



